home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
Snippets
/
PNL Libraries
/
Libraries
/
SpriteWorld
/
SpriteWorld files
/
Utils Pascal
/
SWApplication.p
next >
Wrap
Text File
|
1996-11-02
|
4KB
|
150 lines
unit SWApplication;
interface
{$IFC undefined THINK_Pascal}
uses
Types;
{$ENDC}
{/--------------------------------------------------------------------------------------}
{ SWApplication.h}
{}
{ Created: Sunday, April 11, 1993}
{ By: Tony Myles}
{}
{ Portions Copyright: © 1993 Tony Myles, All rights reserved worldwide.}
{/--------------------------------------------------------------------------------------}
const
kNumberOfMoreMastersCalls = 3;
kWindowResID = 128;
kErrorAlertResID = 128;
kCantRunAlertResID = 129;
kErrorStringListResID = 128;
kFatalErrorStringIndex = 1;
kCantFindResourceStringIndex = 2;
kOutOfMemStringIndex = 3;
kSeriousDamageString = 'Could not even get error string!\rThis application is seriously damaged!';
procedure Initialize (numberOfMasters: integer);
procedure ErrorAlert (err: OSErr; errorStringIndex: integer);
procedure FatalError (err: OSErr);
procedure CantFindResource;
procedure CantRunOnThisMachine;
implementation
{ /-------------------------------------------------------------------------------------- }
{ Initialize }
{ /-------------------------------------------------------------------------------------- }
{$IFC undefined THINK_Pascal}
uses
Events, Memory, Quickdraw, Fonts, Windows, Menus, TextEdit, Dialogs, {}
TextUtils, Errors, SegLoad, Resources;
{$ENDC}
procedure Initialize (numberOfMasters: integer);
var
tempEvent: EventRecord;
junk_boolean: boolean;
i: integer;
begin
MaxApplZone();
{$IFC undefined THINK_Pascal}
for i := 1 to numberOfMasters do begin
MoreMasters;
end;
InitGraf(@qd.thePort);
InitFonts;
InitWindows;
InitMenus;
TEInit;
InitDialogs( nil );
{$ENDC}
InitCursor();
FlushEvents(everyEvent, 0);
for i := 1 to 3 do begin
junk_boolean := EventAvail( everyEvent, tempEvent );
end;
end;
{ /-------------------------------------------------------------------------------------- }
{ ErrorAlert }
{ /-------------------------------------------------------------------------------------- }
procedure ErrorAlert (err: OSErr; errorStringIndex: integer);
var
messageString, errorString: Str255;
dummy: longint;
begin
GetIndString(messageString, kErrorStringListResID, errorStringIndex);
if (length(messageString) = 0) then
messageString := kSeriousDamageString;
{BlockMove(Ptr(kSeriousDamageString), Ptr(messageString), sizeof(kSeriousDamageString));}
NumToString(err, errorString);
ParamText(messageString, errorString, '', '');
dummy := StopAlert(kErrorAlertResID, nil);
end;
{ /-------------------------------------------------------------------------------------- }
{ FatalError }
{ /-------------------------------------------------------------------------------------- }
procedure FatalError (err: OSErr);
begin
if (err <> noErr) then
begin
if (err = memFullErr) then
ErrorAlert(err, kOutOfMemStringIndex)
else
ErrorAlert(err, kFatalErrorStringIndex);
ExitToShell;
end;
end;
{ /-------------------------------------------------------------------------------------- }
{ CantFindResource }
{ /-------------------------------------------------------------------------------------- }
procedure CantFindResource;
var
err: OSErr;
begin
err := ResError;
if (err = noErr) then
err := resNotFound;
ErrorAlert(err, kCantFindResourceStringIndex);
ExitToShell;
end;
{ /-------------------------------------------------------------------------------------- }
{ CantRunOnThisMachine }
{ /-------------------------------------------------------------------------------------- }
procedure CantRunOnThisMachine;
var
dummy: longint;
begin
dummy := StopAlert(kCantRunAlertResID, nil);
end;
end.